package com.situ.day6;

public class ArrayUtil {

    private ArrayUtil() {

    }

    /**
     * 返回数组的最大值
     * @param array 传过来的数组
     * @return 返回数组最大值
     */
    public static int max(int[] array) {
        int max = array[0];
        for (int i = 1; i < array.length; i++) {
            if (max < array[i]) {
                max = array[i];
            }
        }
        return max;
    }

    public static int min(int[] array) {
        return 0;
    }

    // Duplicated code fragment
    public static void bubbleSort(int[] array) {
        if (array == null){
            return;
        }
        for (int i = 1; i <= array.length - 1; i++) {
            for (int j = 0; j < array.length - i; j++) {
                if (array[j] > array[j + 1]) {
                    int temp = array[j];
                    array[j] = array[j + 1];
                    array[j + 1] = temp;
                }
            }
        }
    }
}
